<template>
	<view class="tabs-wrap">
		<u-notice-bar type="warning" mode="horizontal" :is-circular='false' :list="notice_bar_list"></u-notice-bar>
		<view class="content_box">
			<u-form label-width='23' label-position="left" :model="data">
				<u-form-item :border-bottom='true' left-icon="level" :leftIcon-style="{'color': '#fa3534'}">

					<view style="display: flex;    align-items: baseline;">
						<view style="width: 90%;">

							<u-input type='select' @click="flight_inquiry_go()" v-model="data.startTime"
								placeholder="请选择出发时间" :border="false" disabledColor="#ffffff"></u-input>
						</view>
						<view v-if='data.startTime' style="width: 5%;margin-left: 10px;">
							<u-icon @click="startTime_clear()" name="close-circle-fill" color="#ff0000" size="40">
							</u-icon>
						</view>
					</view>
				</u-form-item>
				<u-form-item borderBottom leftIcon="map-fill" :leftIconStyle="{'color': '#2979ff'}">
					<view style="display: flex;    align-items: baseline;">
						<view style="width: 90%;">
							<u-input type='select' @click="input_btn(1)" v-model="data.fromLocation" placeholder="出发地址"
								:border="false" disabledColor="#ffffff"></u-input>
						</view>
						<view v-if='data.fromLocation' style="width: 5%;margin-left: 10px;">
							<u-icon @click="fromLocation_clear()" name="close-circle-fill" color="#ff0000" size="40">
							</u-icon>
						</view>
					</view>

				</u-form-item>
				<u-form-item v-for="(item,index) in passing_points_index" :key="index" left-icon="map-fill"
					:left-icon-style="{'color': 'red'}">
					<view style="display: flex;    align-items: baseline;">
						<div style="width: 90%;">
							<u-input type='select' :border="true" @click="passing_points_map(index)"
								v-model="passing_points_list[index].address" placeholder="途经点" />
						</div>

						<view style="width: 5%;margin-left: 10px;">
							<u-icon @click="passing_points_index_delbtn(index)" name="close-circle-fill" color="#ff0000"
								size="40">
							</u-icon>
						</view>

					</view>
				</u-form-item>
				<u-form-item borderBottom leftIcon="map-fill" :leftIconStyle="{'color': '#19be6b'}">
					<view style="display: flex;    align-items: baseline;">
						<view style="width: 90%;">
							<u-input type='select' @click="input_btn(2)" v-model="data.toLocation" placeholder="目的地址"
								:border="false" disabled disabledColor="#ffffff"></u-input>
						</view>
						<view v-if='data.toLocation' style="width: 5%;margin-left: 10px;">
							<u-icon @click="toLocation_clear()" name="close-circle-fill" color="#ff0000" size="40">
							</u-icon>
						</view>
					</view>

				</u-form-item>
				<u-form-item v-if="radio_off" borderBottom leftIcon="car-fill">
					<u-radio-group v-model="data.radio_value" @change="radioGroupChange">
						<u-radio :name="'包车'">包车</u-radio>
						<u-radio :name="'拼车'">拼车</u-radio>
					</u-radio-group>
				</u-form-item>
			</u-form>
			<view style="margin-top: 40rpx;margin-bottom: 30rpx;display: flex;justify-content:space-evenly;">
				<u-button v-if="data.radio_value != '拼车'" style="width: 30vw;" @click="add_passing_points_btn"
					type="warning">添加途径点</u-button>
				<u-button style="width: 30vw;" @click="next_Btn"
					:disabled="(data.toLocation && data.fromLocation && data.startTime)?false:true"
					type="primary">下一步</u-button>

			</view>
			<view>
				<u-form>
					<u-divider color="#fa3534">智能识别</u-divider>
				</u-form>
				<u-form label-width='90' label-position="left" :model="data">
					<u-form-item borderBottom leftIcon="edit-pen-fill">
						<u-input :border="true" v-model="recognition.remark" :type="'textarea'"
							:custom-style="{'color': '#00C3CE'}" :placeholderStyle="'color: #f000000;'"
							:clearable="false" :auto-height="true" :height="200" :placeholder="'请填写识别信息'" />
					</u-form-item>
					<view style="margin-top: 40rpx;margin-bottom: 30rpx;display: flex;justify-content:space-evenly;">
						<u-button style="width: 30vw;" @click="clear_recognition_Btn" type="warning">清空识别</u-button>
						<u-button style="width: 30vw;" @click="recognition_Btn" type="primary">智能识别</u-button>

					</view>



				</u-form>
			</view>

			<!-- 弹窗 -->
			<template>
				<!-- 飞机 -->
				<div>

					<u-action-sheet @click="action_sheet_select1" @close="action_sheet_close1"
						:list="[{text:'成都天府机场T1'},{text:'成都天府机场T2'},{text:'成都双流机场T1'},{text:'成都双流机场T2'},{text:'地图选址'}]"
						v-model="action_sheet_show1"  round='10'></u-action-sheet>

					<view class="picker_css" v-if="picker_show1">
						<view style="display: flex;justify-content: space-around;margin-top: 10rpx;">
							<view style="width: 70vw;">
								<u-input @input="onChange" v-model="curval1" border='true'
									:placeholder="'请输入地点关键字搜索并选择'" :maxlength="30" :margin="'16rpx'"
									@change="onChange"></u-input>
							</view>
							<view style="width: 20vw;">
								<u-button @click="closeMd" type="primary">地图选址</u-button>
							</view>
						</view>

						<view v-if='getStationListPages_list.length >0' class="list-content">
							<view class="point-item" v-for="(it, index) in getStationListPages_list" :key="index"
								:data-obj="it" @click="picker_confirm1(it)">
								<view class="point-name">
									<u-icon name="map" :color="'#00c3ce'" size="20"></u-icon>
									{{it.address}}
								</view>
								<view class="point-address">{{it.stationName}}</view>
								<!-- 	<u-icon class="point-collect" size="40" name="star" color="#999"></u-icon> -->
							</view>
						</view>
						<view v-else class="list-content">
							<view style="font-weight: 700;margin-top: 200rpx;font-size: 60rpx;text-align: center;">
								暂无数据,请点击地图选址</view>
						</view>
					</view>
				</div>
				<!-- 智能识别 -->
				<view @click="recognition_off_btn" v-if='recognition.recognition_off' class="recognition_css">
					<view>识别</view>
					<view>信息</view>

				</view>
				<view v-if='recognition.recognition_info_off' class="recognition_view">
					<view style="font-weight: 700;font-size: 40rpx;color: #fff;text-align: center;margin-top: 20rpx;">
						识别信息
					</view>
					<view>
						<view style="display: flex;justify-content: space-evenly;margin-top: 20rpx;">
							<view style="width: 250rpx;">
								<u-button @click="banci_btn(recognition.recognition_info)" type="primary">班次</u-button>
							</view>
							<view style="width: 250rpx;">
								<u-button @click="time_btn(recognition.recognition_info)" type="primary">时间</u-button>
							</view>
						</view>
						<view style="display: flex;justify-content: space-evenly;margin-top: 20rpx;">
							<view style="width: 250rpx;">
								<u-button @click="chufadi_btn(recognition.recognition_info)"
									type="primary">出发地</u-button>
							</view>
							<view style="width: 250rpx;">
								<u-button @click="mudidi_btn(recognition.recognition_info)"
									type="primary">目的地</u-button>
							</view>
						</view>



					</view>
					<view style=" width: 80%;margin: auto;margin-top: 30rpx;">
						<u-button @click="recognition_info_off_btn" type="warning">关闭</u-button>
					</view>
				</view>

			</template>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				notice_bar_list: [
					'送机:请先选择目的地址的机场站点',
				],
				recognition: {
					remark: '',
					recognition_info: {},
					recognition_off: false,
					recognition_info_off: false,
				},
				// 数据
				data: {
					startTime: '',
					fromLocation: '',
					fromLocationId: '',
					fromLocationData: {
						address: '',
						area: '',
						id: "",
						isSta: "",
						lnglat: "",
						name: "",
						tel: "",
						type: ""
					},
					toLocation: '',
					toLocationId: '',
					toLocationData: {
						address: '',
						area: '',
						id: "",
						isSta: "",
						lnglat: "",
						name: "",
						tel: "",
						type: ""
					},
					flightNum: '',
					flightDate: '',
					landDate: '',
					type: '1',
					useDays: '',
					radio_value: '包车',

				},
				findStationCombo_list: [],
				action_sheet_show1: false,
				picker_show1: false,
				getStationListPages_list: [],
				input_data: '1',
				radio_off: false,
				passing_points_list: [],
				passing_points_index: 0,

				curval1: '',
			}
		},
		onLoad(e) {
			console.log(e, ' --- onLoad')

		},
		mounted() {

			let that = this


			let recognition_remark = uni.getStorageSync('recognition_remark');
			let recognition_info = uni.getStorageSync('recognition_info');
			that.recognition.recognition_info = recognition_info
			if (recognition_remark) {
				that.recognition.recognition_off = true
			} else {
				that.recognition.recognition_off = false
			}

			that.recognition.remark = recognition_remark

			that.$u.api.findStationCombo({
				page: {
					pageNum: 1,
					pageSize: 999,
				},
				stationTypes: ['AIRPORT']
			}).then(res => {
				that.findStationCombo_list = res.data.list
			})
			console.log(' --- mounted')
			let aircraft = uni.getStorageSync('aircraft');
			if (aircraft) {
				uni.removeStorageSync('aircraft');
				that.data.startTime = aircraft.timedate
				if (aircraft.flightNo) {
					if (aircraft.depPort.includes('天府') && aircraft.depPort.includes('机场')) {
						// 送飞机
						that.data.type = '1'
						if (aircraft.depTerminal.includes('1')) {
							that.data.toLocation = '成都天府机场T1'
						} else if (aircraft.depTerminal.includes('2')) {
							that.data.toLocation = '成都天府机场T2'
						} else {
							that.data.toLocation = '成都天府机场T1'
						}
						that.$u.api.findStationCombo({
							page: {
								pageNum: 1,
								pageSize: 999,
							},
							stationTypes: ['AIRPORT']
						}).then(res => {
							if (res.code == 1) {
								for (let i = 0; i < res.data.list.length; i++) {
									if (that.data.toLocation == res.data.list[i].station_name) {
										that.data.toLocationData.address = res.data.list[i].station_name
										that.data.toLocationData.area = res.data.list[i].station_name
										that.data.toLocationData.lnglat = res.data.list[i].lng_lat
										that.data.toLocationData.id = res.data.list[i].id
										that.data.toLocationId = res.data.list[i].id

									}
								}
							}
						})


					} else if (aircraft.depPort.includes('双流') && aircraft.depPort.includes('机场')) {
						// 送飞机
						if (aircraft.depTerminal.includes('1')) {
							that.data.toLocation = '成都双流机场T1'
						} else if (aircraft.depTerminal.includes('2')) {
							that.data.toLocation = '成都双流机场T2'
						} else {
							that.data.toLocation = '成都双流机场T1'
						}
						that.$u.api.findStationCombo({
							page: {
								pageNum: 1,
								pageSize: 999,
							},
							stationTypes: ['AIRPORT']
						}).then(res => {
							if (res.code == 1) {
								for (let i = 0; i < res.data.list.length; i++) {
									if (that.data.toLocation == res.data.list[i].station_name) {
										that.data.toLocationData.address = res.data.list[i].station_name
										that.data.toLocationData.area = res.data.list[i].station_name
										that.data.toLocationData.lnglat = res.data.list[i].lng_lat
										that.data.toLocationData.id = res.data.list[i].id
										that.data.toLocationId = res.data.list[i].id

									}
								}
							}
						})
					} else if (aircraft.arrPort.includes('天府') && aircraft.arrPort.includes('机场')) {
						// 接飞机
						if (aircraft.arrTerminal.includes('1')) {
							that.data.fromLocation = '成都天府机场T1'
						} else if (aircraft.arrTerminal.includes('2')) {
							that.data.fromLocation = '成都天府机场T2'
						} else {
							that.data.fromLocation = '成都天府机场T2'
						}
						that.data.type = '1'
						that.$u.api.findStationCombo({
							page: {
								pageNum: 1,
								pageSize: 999,
							},
							stationTypes: ['AIRPORT']
						}).then(res => {
							if (res.code == 1) {
								for (let i = 0; i < res.data.list.length; i++) {
									if (that.data.fromLocation == res.data.list[i].station_name) {
										that.data.fromLocationData.address = res.data.list[i].station_name
										that.data.fromLocationData.area = res.data.list[i].station_name
										that.data.fromLocationData.lnglat = res.data.list[i].lng_lat
										that.data.fromLocationData.id = res.data.list[i].id
										that.data.fromLocationId = res.data.list[i].id

									}
								}
							}
						})
					} else if (aircraft.arrPort.includes('双流') && aircraft.arrPort.includes('机场')) {
						// 接飞机
						if (aircraft.arrTerminal.includes('1')) {
							that.data.fromLocation = '成都双流机场T1'
						} else if (aircraft.arrTerminal.includes('2')) {
							that.data.fromLocation = '成都双流机场T2'
						} else {
							that.data.fromLocation = '成都双流机场T2'
						}
						that.$u.api.findStationCombo({
							page: {
								pageNum: 1,
								pageSize: 999,
							},
							stationTypes: ['AIRPORT']
						}).then(res => {
							if (res.code == 1) {
								for (let i = 0; i < res.data.list.length; i++) {
									if (that.data.fromLocation == res.data.list[i].station_name) {
										that.data.fromLocationData.address = res.data.list[i].station_name
										that.data.fromLocationData.area = res.data.list[i].station_name
										that.data.fromLocationData.lnglat = res.data.list[i].lng_lat
										that.data.fromLocationData.id = res.data.list[i].id
										that.data.fromLocationId = res.data.list[i].id

									}
								}
							}
						})
					}
					that.data.flightNum = aircraft.flightNo
					that.data.flightDate = aircraft.depScheduled
					that.data.landDate = aircraft.arrScheduled

				}

			}

		},
		watch: {
			data: {
				handler(newValue, oldValue) {
					// 当myObject发生变化时，这里会被调用
					console.log('Object changed:', newValue, oldValue);
					if (newValue.fromLocation.includes('成都天府机场T') || newValue.toLocation.includes('成都天府机场T')) {
						this.radio_off = true
					} else {
						this.radio_off = false
						this.data.radio_value = '包车'
					}
					if (newValue.type == 0) {
						this.passing_points_list = []
						this.passing_points_index = 0
					}

				},
				deep: true // 开启深度监听
			}
		},
		methods: {
			// start 智能识别
			clear_recognition_Btn() {
				uni.removeStorageSync('recognition_remark');
				uni.removeStorageSync('recognition_info');
				this.recognition.recognition_off = false
				this.recognition.recognition_info_off = false
				this.recognition.remark = ''
				uni.showToast({
					title: "智能识别信息已清空",
					icon: "none",
					duration: 1000
				})
			},
			recognition_Btn() {
				let that = this
				let remark = that.recognition.remark
				if (!remark) {
					return uni.showToast({
						title: "识别失败,识别信息为空",
						icon: "none",
						duration: 1000
					})
				}
				if (remark.split('@')) {
					let data = remark.split('@')
					let recognition_info = {
						banci: '',
						time: '',
						chufadi: '',
						mudidi: '',
						kehu: '',
						phone: '',
						people: '',
						car: '',
						yewuyuanbeizhu: '',
						kehubeizhu: '',
					}
					// 班次
					let banci = data.find(element => element.includes("班次："))
					if (banci) {
						let shiftInfo = banci.split("班次：")[1]
						recognition_info.banci = shiftInfo.trim()
					}
					// 时间
					let time = data.find(element => element.includes("时间："))
					if (time) {
						let shiftInfo = time.split("时间：")[1]
						recognition_info.time = shiftInfo.trim()
					}
					// 出发地
					let chufadi = data.find(element => element.includes("出发地："))
					if (chufadi) {
						let shiftInfo = chufadi.split("出发地：")[1]
						recognition_info.chufadi = shiftInfo.trim()
					}
					// 目的地
					let mudidi = data.find(element => element.includes("目的地："))
					if (mudidi) {
						let shiftInfo = mudidi.split("目的地：")[1]
						recognition_info.mudidi = shiftInfo.trim()
					}
					// 客户
					let kehu = data.find(element => element.includes("客户："))
					if (kehu) {
						let shiftInfo = kehu.split("客户：")[1]
						recognition_info.kehu = shiftInfo.trim()
					}
					// 电话
					let phone = data.find(element => element.includes("电话："))
					if (phone) {
						let shiftInfo = phone.split("电话：")[1]
						recognition_info.phone = shiftInfo.trim()
					}
					// 人数
					let people = data.find(element => element.includes("人数："))
					if (people) {
						let shiftInfo = people.split("人数：")[1]
						recognition_info.people = shiftInfo.trim()
					}
					// 车型
					let car = data.find(element => element.includes("车型："))
					if (car) {
						let shiftInfo = car.split("车型：")[1]
						recognition_info.car = shiftInfo.trim()
					}
					// 业务员备注
					let yewuyuanbeizhu = data.find(element => element.includes("业务员备注："))
					if (yewuyuanbeizhu) {
						let shiftInfo = yewuyuanbeizhu.split("业务员备注：")[1]
						recognition_info.yewuyuanbeizhu = shiftInfo.trim()
					}
					// 客户备注
					let kehubeizhu = data.find(element => element.includes("客户备注："))
					if (kehubeizhu) {
						let shiftInfo = kehubeizhu.split("客户备注：")[1]
						recognition_info.kehubeizhu = shiftInfo.trim()
					}

					console.log(recognition_info, 'recognition_info');
					uni.setStorageSync('recognition_remark', remark)
					uni.setStorageSync('recognition_info', recognition_info)
					that.recognition.recognition_info = recognition_info
					that.recognition.recognition_off = true
					uni.showToast({
						title: "识别成功",
						icon: "none",
						duration: 1000
					})

				} else {
					uni.showToast({
						title: "识别失败,请检测识别信息是否正确",
						icon: "none",
						duration: 1000
					})
				}



			},
			recognition_off_btn() {
				this.recognition.recognition_info_off = !this.recognition.recognition_info_off
			},
			banci_btn(e) {
				let that = this
				let info = e.banci
				let date = e.time
				if (info) {
					let now = new Date()
					let year = now.getFullYear()
					const str = date // 或者 "6月12日12:11"		
					let parts = str.split(/月|日|\s/).filter(part => part !== "") // 使用正则表达式和空格作为分隔符进行分割并过滤空字符串					
					const month = parseInt(parts[0]) // 提取月份
					const day = parseInt(parts[1]) // 提取日期
					const time = parts[2] // 提取时间
					date = year + '-' + month + '-' + day
					console.log(date)
					uni.navigateTo({
						url: '/order-man/charter-a-car/travel/aircraft?info=' + info +
							'&date=' + date
					})
				} else {
					uni.showToast({
						title: "班次信息为空，请检查后重新识别",
						icon: "none",
						duration: 1000
					})
				}
			},
			time_btn(e) {
				let that = this
				let info = e.time
				let date = info

				if (info) {
					let now = new Date()
					let year = now.getFullYear()
					const str = date // 或者 "6月12日12:11"		
					let parts = str.split(/月|日|\s/).filter(part => part !== "") // 使用正则表达式和空格作为分隔符进行分割并过滤空字符串					
					const month = parseInt(parts[0]) // 提取月份
					const day = parseInt(parts[1]) // 提取日期
					const time = parts[2] // 提取时间
					date = year + '-' + month + '-' + day + ' ' + time

					that.data.startTime = date
				} else {
					uni.showToast({
						title: "时间为空，请检查后重新识别",
						icon: "none",
						duration: 1000
					})
				}
			},
			chufadi_btn(e) {
				let that = this
				let info = e.chufadi
				let date = info
				that.input_data = 1
				if (info) {
					if (that.data.fromLocation.includes('成都天府机场T') || that.data.fromLocation.includes('成都双流机场T')) {
						that.action_sheet_show1 = true
					} else if (that.data.toLocation.includes('成都天府机场T') || that.data.toLocation.includes('成都双流机场T')) {
						that.getStationListPages_api(0)
						that.curval1 = date
						that.picker_show1 = true
					} else {
						that.action_sheet_show1 = true
					}


				} else {
					uni.showToast({
						title: "出发地为空，请检查后重新识别",
						icon: "none",
						duration: 1000
					})
				}
			},

			mudidi_btn(e) {
				let that = this
				let info = e.mudidi
				let date = info
				that.input_data = 2
				if (info) {
					if (that.data.toLocation.includes('成都天府机场T') || that.data.toLocation.includes('成都双流机场T')) {
						that.action_sheet_show1 = true
					} else if (that.data.fromLocation.includes('成都天府机场T') || that.data.fromLocation.includes('成都双流机场T')) {
						that.getStationListPages_api(0)
						that.curval1 = date
						that.picker_show1 = true
					} else {
						that.action_sheet_show1 = true
					}
				} else {
					uni.showToast({
						title: "目的地为空，请检查后重新识别",
						icon: "none",
						duration: 1000
					})
				}
			},
			recognition_info_off_btn() {
				this.recognition.recognition_info_off = false
			},
			// end
			flight_inquiry_go() {
				uni.navigateTo({
					url: '/order-man/charter-a-car/travel/aircraft'
				})
			},

			action_sheet_close1() {
				this.action_sheet_show1 = false
			},
			action_sheet_select1(e) {
				let data = ''
				if (e == 0) {
					data = '成都天府机场T1'
				} else if (e == 1) {
					data = '成都天府机场T2'
				} else if (e == 2) {
					data = '成都双流机场T1'
				} else if (e == 3) {
					data = '成都双流机场T2'
				} else if (e == 4) {
					data = '地图选址'
				}
				
				if(data == '地图选址'){
					this.getStationListPages_api(0)
					this.curval1 = ''
					this.picker_show1 = true
				}else{
					for (let i = 0; i < this.findStationCombo_list.length; i++) {
						if (data == this.findStationCombo_list[i].station_name) {
							if (this.input_data == 1) {
								this.data.fromLocationData.address = this.findStationCombo_list[i].station_name
								this.data.fromLocationData.area = this.findStationCombo_list[i].station_name
								this.data.fromLocationData.lnglat = this.findStationCombo_list[i].lng_lat
								this.data.fromLocationData.id = this.findStationCombo_list[i].id
								this.data.fromLocationId = this.findStationCombo_list[i].id
								this.data.fromLocation = this.findStationCombo_list[i].station_name
							} else if (this.input_data == 2) {
								this.data.toLocationData.address = this.findStationCombo_list[i].station_name
								this.data.toLocationData.area = this.findStationCombo_list[i].station_name
								this.data.toLocationData.lnglat = this.findStationCombo_list[i].lng_lat
								this.data.toLocationData.id = this.findStationCombo_list[i].id
								this.data.toLocationId = this.findStationCombo_list[i].id
								this.data.toLocation = this.findStationCombo_list[i].station_name
							} else {
								uni.$u.toast('很抱歉，站点地址错误');
							}
					
						}
					}
				}
				
				
			},
			input_btn(e) {
				let that = this
				that.input_data = e
				if (e == 1) {
					if (that.data.fromLocation.includes('成都天府机场T') || that.data.fromLocation.includes('成都双流机场T')) {
						that.action_sheet_show1 = true
					} else if (that.data.toLocation.includes('成都天府机场T') || that.data.toLocation.includes('成都双流机场T')) {
						that.getStationListPages_api(1)
						that.picker_show1 = true
					} else {
						that.action_sheet_show1 = true
					}


				} else if (e == 2) {
					if (that.data.toLocation.includes('成都天府机场T') || that.data.toLocation.includes('成都双流机场T')) {
						that.action_sheet_show1 = true
					} else if (that.data.fromLocation.includes('成都天府机场T') || that.data.fromLocation.includes('成都双流机场T')) {
						that.getStationListPages_api(1)
						that.picker_show1 = true
					} else {
						that.action_sheet_show1 = true
					}
				} else {
					uni.$u.toast('很抱歉，地址错误');
				}

			},

			onChange() {
				this.getStationListPages_api()
			},
			closeMd(e) {

				let that = this
				if (that.input_data == 1) {
					uni.chooseLocation({
						success: (res) => {
							console.log(res)
							
							that.data.fromLocationData.address = res.address,
								that.data.fromLocationData.area = res.address,
								that.data.fromLocationData.name = res.name,
								that.data.fromLocationData.lnglat = res.longitude + ',' + res.latitude,
								that.data.fromLocation = res.name
						},
						fail: () => {
							// 如果用uni.chooseLocation没有获取到地理位置，则需要获取当前的授权信息，判断是否有地理授权信息
							uni.getSetting({
								success: (res) => {
									var status = res.authSetting;
									if (!status['scope.userLocation']) {
										// 如果授权信息中没有地理位置的授权，则需要弹窗提示用户需要授权地理信息
										uni.showModal({
											title: "是否授权当前位置",
											content: "需要获取您的地理位置，请确认授权，否则地图功能将无法使用",
											success: (tip) => {
												if (tip.confirm) {
													// 如果用户同意授权地理信息，则打开授权设置页面，判断用户的操作
													uni.openSetting({
														success: (
															data
														) => {
															// 如果用户授权了地理信息在，则提示授权成功
															if (data
																.authSetting[
																	'scope.userLocation'
																] ===
																true
															) {
																uni.showToast({
																	title: "授权成功",
																	icon: "success",
																	duration: 1000
																})
																// 授权成功后，然后再次chooseLocation获取信息
																uni.chooseLocation({
																	success: (
																		res
																	) => {
																		that.data.fromLocationData.address = res.address,
																			that.data.fromLocationData.area = res.address,
																			that.data.fromLocationData.name = res.name,
																			that.data.fromLocationData.lnglat = res.longitude + ',' + res.latitude,
																			that.data.fromLocation = res.name
																	}
																})
															} else {
																uni.showToast({
																	title: "授权失败",
																	icon: "none",
																	duration: 1000
																})
															}
														}
													})
												}
											}
										})
									}
								},
								fail: (res) => {
									uni.showToast({
										title: "调用授权窗口失败",
										icon: "none",
										duration: 1000
									})
								}
							})
						}
					});

				} else if (that.input_data == 2) {
					uni.chooseLocation({
						success: (res) => {
							that.data.toLocationData.address = res.address,
								that.data.toLocationData.area = res.address,
								that.data.toLocationData.name = res.name,
								that.data.toLocationData.lnglat = res.longitude + ',' + res.latitude,
								that.data.toLocation = res.name
						},
						fail: () => {
							// 如果用uni.chooseLocation没有获取到地理位置，则需要获取当前的授权信息，判断是否有地理授权信息
							uni.getSetting({
								success: (res) => {
									var status = res.authSetting;
									if (!status['scope.userLocation']) {
										// 如果授权信息中没有地理位置的授权，则需要弹窗提示用户需要授权地理信息
										uni.showModal({
											title: "是否授权当前位置",
											content: "需要获取您的地理位置，请确认授权，否则地图功能将无法使用",
											success: (tip) => {
												if (tip.confirm) {
													// 如果用户同意授权地理信息，则打开授权设置页面，判断用户的操作
													uni.openSetting({
														success: (
															data
														) => {
															// 如果用户授权了地理信息在，则提示授权成功
															if (data
																.authSetting[
																	'scope.userLocation'
																] ===
																true
															) {
																uni.showToast({
																	title: "授权成功",
																	icon: "success",
																	duration: 1000
																})
																// 授权成功后，然后再次chooseLocation获取信息
																uni.chooseLocation({
																	success: (
																		res
																	) => {
																		that.data.toLocationData.address = res.address,
																			that.data.toLocationData.area = res.address,
																			that.data.toLocationData.name = res.name,
																			that.data.toLocationData.lnglat = res.longitude + ',' + res.latitude,
																			that.data.toLocation = res.name
																	}
																})
															} else {
																uni.showToast({
																	title: "授权失败",
																	icon: "none",
																	duration: 1000
																})
															}
														}
													})
												}
											}
										})
									}
								},
								fail: (res) => {
									uni.showToast({
										title: "调用授权窗口失败",
										icon: "none",
										duration: 1000
									})
								}
							})
						}
					});

				} else {
					uni.$u.toast('很抱歉，自选地址错误');
				}



				that.picker_show1 = false
			},
			picker_confirm1(e) {
				let that = this
				console.log(that.input_data,e,'111')
				if (that.input_data == 1) {
					that.data.fromLocationData.address = e.address
					that.data.fromLocationData.area = e.address
					that.data.fromLocationData.lnglat = e.lngLat
					that.data.fromLocationData.name = e.address
					that.data.fromLocation = e.address
					that.data.fromLocationId = e.id
				} else if (that.input_data == 2) {
					that.data.toLocationData.address = e.address
					that.data.toLocationData.area = e.address
					that.data.toLocationData.lnglat = e.lngLat
					that.data.toLocationData.name = e.address
					that.data.toLocation = e.address
					that.data.toLocationId = e.id
				} else {
					uni.$u.toast('很抱歉，自选站点地址错误');
				}
				that.picker_show1 = false
			},
			getStationListPages_api(e) {
				let that = this,
					U = that.U;
				that.$u.api.getStationListPages({
					page: {
						pageNum: 1,
						pageSize: 999,
					},
					find: e == '1' ? '' : that.curval1,
					stationTypes: e == '1' ? ['DIY'] : [],
				}).then(res => {
					if (res.code == 1) {
						let ps = res.data.list
						let ps_list = []

						for (let i = 0; i < ps.length; i++) {
							let obj = {}
							obj.stationName = ps[i].belongProvince + '-' + ps[i].belongCity + '-' + ps[
									i]
								.belongCounty + '-' + ps[i].address
							obj.address = ps[i].stationName
							obj.id = ps[i].id
							obj.lngLat = ps[i].lngLat
							obj.name = ps[i].stationName
							ps_list.push(obj)

						}

						that.getStationListPages_list = ps_list


					} else {
						U.qerror(res.msg);
					}
				})

			},
			radioGroupChange() {
				if (this.data.radio_value == '包车') {
					this.data.radio_value = '包车'
					this.data.type = 1
				} else if (this.data.radio_value == '拼车') {
					this.data.radio_value = '拼车'
					this.data.type = 0
				} else {
					uni.$u.toast('很抱歉，包车拼车错误');
				}
			},
			add_passing_points_btn(e) {
				if (this.passing_points_index < 5) {
					let data = {
						id: '',
						address: '',
						lnglat: '',
						area: '',
						isSta: '',
						name: '',
						tel: '',
						type: '',
					}
					this.passing_points_list.push(data)
					this.passing_points_index += 1
				} else {
					uni.showToast({
						title: "最多添加5个途径点",
						icon: "none",
						duration: 2000
					})
				}
			},
			passing_points_map(e) {

				let that = this
				uni.chooseLocation({
					success: (res) => {

						that.passing_points_list[e].area = res.name
						that.passing_points_list[e].name = res.name
						that.passing_points_list[e].address = res.name
						that.passing_points_list[e].id = ''
						that.passing_points_list[e].lnglat = res.longitude + ',' + res.latitude

					},
					fail: () => {
						// 如果用uni.chooseLocation没有获取到地理位置，则需要获取当前的授权信息，判断是否有地理授权信息
						uni.getSetting({
							success: (res) => {
								var status = res.authSetting;
								if (!status['scope.userLocation']) {
									// 如果授权信息中没有地理位置的授权，则需要弹窗提示用户需要授权地理信息
									uni.showModal({
										title: "是否授权当前位置",
										content: "需要获取您的地理位置，请确认授权，否则地图功能将无法使用",
										success: (tip) => {
											if (tip.confirm) {
												// 如果用户同意授权地理信息，则打开授权设置页面，判断用户的操作
												uni.openSetting({
													success: (
														data) => {
														// 如果用户授权了地理信息在，则提示授权成功
														if (data
															.authSetting[
																'scope.userLocation'
															] ===
															true
														) {
															uni.showToast({
																title: "授权成功",
																icon: "success",
																duration: 1000
															})
															// 授权成功后，然后再次chooseLocation获取信息
															uni.chooseLocation({
																success: (
																	res
																) => {
																	that.passing_points_list[
																			e
																		]
																		.area =
																		res
																		.name
																	that.passing_points_list[
																			e
																		]
																		.name =
																		res
																		.name
																	that.passing_points_list[
																			e
																		]
																		.address =
																		res
																		.name
																	that.passing_points_list[
																			e
																		]
																		.id =
																		''
																	that.passing_points_list[
																			e
																		]
																		.lnglat =
																		res
																		.longitude +
																		',' +
																		res
																		.latitude


																}
															})
														} else {
															uni.showToast({
																title: "授权失败",
																icon: "none",
																duration: 1000
															})
														}
													}
												})
											}
										}
									})
								}
							},
							fail: (res) => {
								uni.showToast({
									title: "调用授权窗口失败",
									icon: "none",
									duration: 1000
								})
							}
						})
					}
				});
			},
			passing_points_index_delbtn(index) {
				this.passing_points_index -= 1
				this.passing_points_list.splice(index, 1)
			},
			startTime_clear() {
				this.data.startTime = ''
			},
			fromLocation_clear() {
				this.data.fromLocation = ''
				this.data.fromLocationId = ''
				this.data.fromLocationData.address = ''
				this.data.fromLocationData.area = ''
				this.data.fromLocationData.id = ''
				this.data.fromLocationData.isSta = ''
				this.data.fromLocationData.lnglat = ''
				this.data.fromLocationData.name = ''
				this.data.fromLocationData.tel = ''
				this.data.fromLocationData.type = ''

			},
			toLocation_clear() {
				this.data.toLocation = ''
				this.data.toLocationId = ''
				this.data.toLocationData.address = ''
				this.data.toLocationData.area = ''
				this.data.toLocationData.id = ''
				this.data.toLocationData.isSta = ''
				this.data.toLocationData.lnglat = ''
				this.data.toLocationData.name = ''
				this.data.toLocationData.tel = ''
				this.data.toLocationData.type = ''
			},
			next_Btn() {
				// 第一步判断：1.出发时间，2.降落时间，3,起飞时间，4出发地址，5目的地址，6，途径点，7，包车还是拼车type,8行程简称
				let that = this
				let now = new Date() // 获取当前时间的 Date 对象
				let timestamp = now.getTime() // 获取当前时间的时间戳		
				let threeHoursLater = new Date(timestamp + (4 * 60 * 60 * 1000)) // 计算四个小时前的时间的 Date 对象
				let threeHoursLaterTimestamp = threeHoursLater.getTime() // 获取三个小时后的时间的时间戳	
				let dateTimeString = that.data.startTime // 要转换的日期时间字符串
				let dateParts = dateTimeString.split(" ") // 分割日期和时间部分
				let date = dateParts[0].split("-") // 分割日期的年、月、日
				let time = dateParts[1].split(":") // 分割时间的小时、分钟	
				let year = parseInt(date[0])
				let month = parseInt(date[1]) - 1 // 注意月份要减1
				let day = parseInt(date[2])
				let hours = parseInt(time[0])
				let minutes = parseInt(time[1])
				let timestamp2 = new Date(year, month, day, hours, minutes).getTime()
				// if (!(timestamp2 >= threeHoursLaterTimestamp)) {
				// 	return uni.$u.toast('抱歉,距出发少于4小时，无法准备车辆');
				// }
				let ps = {
					startTime: '',
					endTime: '',
					flightNum: '',
					routeSimpleName: '',
					flightDate: '',
					landDate: '',
					fromLocationId: '',
					fromLocation: '',
					fromLocationData: {
						address: '',
						area: '',
						id: '',
						isSta: '',
						lnglat: '',
						name: '',
						tel: '',
						type: '',
					},
					toLocation: '',
					toLocationId: '',
					toLocationData: {
						address: '',
						area: '',
						id: '',
						isSta: '',
						lnglat: '',
						name: '',
						tel: '',
						type: '',
					},
					type: '',
					points: [],
					useDays: '',
				}
				ps.startTime = that.data.startTime + ':00'
				ps.endTime = that.data.endTime ? that.data.endTime + ':00' : ''
				ps.flightNum = that.data.flightNum
				if (that.data.fromLocation.includes('成都天府机场T1') || that.data.fromLocation.includes('成都天府机场T2')) {
					if (that.data.type == 0) {
						ps.routeSimpleName = '拼车接天府'
					} else if (that.data.type == 1) {
						ps.routeSimpleName = '接天府'
					} else {
						return uni.$u.toast('抱歉,拼车订单错误');
					}
				} else if (that.data.fromLocation.includes('成都双流机场T1') || that.data.fromLocation.includes('成都双流机场T2')) {
					ps.routeSimpleName = '接双流'
				} else if (that.data.toLocation.includes('成都天府机场T1') || that.data.toLocation.includes('成都天府机场T2')) {
					if (that.data.type == 0) {
						ps.routeSimpleName = '拼车送天府'
					} else if (that.data.type == 1) {
						ps.routeSimpleName = '送天府'
					} else {
						return uni.$u.toast('抱歉,拼车订单错误');
					}
				} else if (that.data.toLocation.includes('成都双流机场T1') || that.data.toLocation.includes('成都双流机场T2')) {
					ps.routeSimpleName = '送双流'
				} else {
					return uni.$u.toast('抱歉,订单信息错误，请检查订单');
				}
				if (ps.routeSimpleName.includes('接')) {
					ps.landDate = ps.startTime
				} else if (ps.routeSimpleName.includes('送')) {
					ps.flightDate = ps.startTime
				}

				ps.fromLocationId = that.data.fromLocationId
				ps.fromLocation = that.data.fromLocation
				ps.fromLocationData.address = that.data.fromLocationData.address
				ps.fromLocationData.area = that.data.fromLocationData.area
				ps.fromLocationData.id = that.data.fromLocationData.id
				ps.fromLocationData.isSta = that.data.fromLocationData.isSta
				ps.fromLocationData.lnglat = that.data.fromLocationData.lnglat
				ps.fromLocationData.name = that.data.fromLocationData.name
				ps.fromLocationData.tel = that.data.fromLocationData.tel
				ps.fromLocationData.type = that.data.fromLocationData.type

				ps.toLocationId = that.data.toLocationId
				ps.toLocation = that.data.toLocation
				ps.toLocationData.address = that.data.toLocationData.address
				ps.toLocationData.area = that.data.toLocationData.area
				ps.toLocationData.id = that.data.toLocationData.id
				ps.toLocationData.isSta = that.data.toLocationData.isSta
				ps.toLocationData.lnglat = that.data.toLocationData.lnglat
				ps.toLocationData.name = that.data.toLocationData.name
				ps.toLocationData.tel = that.data.toLocationData.tel
				ps.toLocationData.type = that.data.toLocationData.type
				ps.type = that.data.type
				ps.useDays = that.data.useDays
				console.log(that.passing_points_list)
				for (let i = 0; i < that.passing_points_list.length; i++) {
					if (that.passing_points_list[i].address && that.passing_points_list[i].lnglat) {
						ps.points.push(that.passing_points_list[i])
					}

				}
				console.log(ps)
				uni.setStorageSync('recognition_remark', that.recognition.remark)
				uni.setStorageSync('perfect_info_data', ps);
				uni.navigateTo({
					url: '/order-man/charter-a-car/travel/perfect-info'
				})
				console.log(ps, '下一步')

			},

		}
	}
</script>

<style lang="scss">
	.recognition_view {
		z-index: 9999;
		position: fixed;
		top: 650rpx;
		left: calc(100vw - 90vw);
		width: 80vw;
		height: 30vh;
		background-color: #a6a6a6;
		border-radius: 8rpx;

	}

	.recognition_css {
		z-index: 8888;
		font-weight: 700;
		font-size: 30rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-wrap: wrap;
		flex-direction: column;
		top: 920rpx;
		right: 10rpx;
		border-radius: 50%;
		width: 120rpx;
		height: 120rpx;
		background-color: #00C3CE;
		position: fixed;
		color: #ffffff
	}

	.content_box {
		width: 90%;
		margin: auto;
		height: 70vh;
		background-color: #fff;
		border-radius: 10rpx;
		padding: 10rpx 20rpx;
		overflow: auto;
	}

	.u-form-item {
		padding: 10rpx 0 !important;
	}

	.picker_css {

		width: 100vw;
		height: 100vh;
		z-index: 9999;
		position: fixed;
		top: 0;
		left: 0;
		background-color: #fff;
	}

	.list-content {
		height: calc(100vh - 150rpx);
		overflow: auto;
		margin-top: 10rpx;

		.point-item {
			border-bottom: 2rpx solid #efefef;
			line-height: 44rpx;
			padding: 10rpx 60rpx 10rpx 20rpx;
			position: relative;

			.point-name {
				display: flex;
				font-weight: 600;
				font-size: 30rpx;
				color: #333;
			}

			.point-address {
				color: #999;
				font-size: 26rpx;
			}

			.point-collect {
				top: calc((100% - 40rpx)/2);
				right: 20rpx;
				position: absolute;
			}
		}
	}
</style>